<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>添加/修改公告信息</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script> 
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
</head>
<body>
<div class="pd-10">
  <form action="" method="post" class="form form-horizontal" id="myform">
    <div class="row cl">
      <label class="form-label col-2"><span class="c-red">*</span>公告标题：</label>
      <div class="formControls col-9">
        <input type="text" class="input-text" placeholder="请输入公告标题" id="nname" name="nname" value="{$res.no_title}">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-2"><span class="c-red">*</span>公告类型：</label>
      <div class="formControls col-9"> <span class="select-box">
        <select class="select" size="1" id="ntype" name="ntype">
          <volist name='ntype' id='vo' key='k'>
           <option value="{$k}" <if condition='($res[no_cid] eq $k)'>selected</if>>{$vo}</option>
          </volist>
        </select></span>
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-2"><span class="c-red">*</span>公告内容：</label>
      <div class="formControls col-9">
        <textarea id="editor" name="nbody" style="height:300px;max-height:500px;">{$res.no_body|htmlspecialchars_decode}</textarea>
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" name="id" value="{$res.no_id}">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <button class="btn btn-default radius" type="button" onClick="layer_close();"><i class='Hui-iconfont'>&#xe66b;</i> 取消</button>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit()
{
	var nname = $.trim($('#nname').val());
	var ntype = $.trim($('#ntype').val());
	var nbody = $.trim($('#editor').val());
	if(nname == ''){
		layer.msg('公告标题不能为空', {icon: 2});
		return false;
	}if(nbody == ''){
		layer.msg('公告内容不能为空', {icon: 2});
		return false;
	}
	$.ajax({
		type : 'post',
		url : '__MODULE__/Setup/notiAddEdit',
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1,time:2000},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
				parent.call_back_fun('success');
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script>
<!-- 文本编辑器 -->
<!--引入wangEditor.css-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/lib/wangEditor/css/wangEditor.min.css">
<!--注意：javascript必须放在body最后，否则可能会出现问题-->
<script type="text/javascript" src="__PUBLIC__/lib/wangEditor/js/wangEditor.min.js"></script>
<script type="text/javascript">
    var editor = new wangEditor('editor');
	// 仅仅想移除某几个菜单，例如想移除『插入代码』和『全屏』菜单：
    // 其中的 wangEditor.config.menus 可获取默认情况下的菜单配置
    editor.config.menus = $.map(wangEditor.config.menus, function(item, key) {
    	if (item === 'insertcode') return null;
    	if (item === 'fullscreen') return null;
		if (item === 'img') return null;
		if (item === 'video') return null;
		if (item === 'location') return null;
		if (item === 'table') return null;
		if (item === 'emotion') return null;
		if (item === 'quote') return null;
		if (item === 'bgcolor') return null;
		return item;
    });
    editor.create();
</script>
<!-- 文本编辑器-->
</body>
</html>